/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-26 15:51:46
 * @LastEditTime : 2023-05-26 15:54:19
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\SecurityProblemType.jsx
 * @Description  :
 */
/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-13 11:02:18
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-08 14:37:48
 * @FilePath: \adminstration\src\Common\Router\MenuNavList\Security\SecurityProblemType.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { SecurityProblemTypeTree } from '../Common/Conversion'

export const SecurityProblemType = async ({ url, OptionsEvent, Permission }) => {
    const parentUuid = await SecurityProblemTypeTree()
    let data = {
        type: '安全管理',
        pageSize: 100,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}Tree`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '31cae59a-017c-40df-bba7-a4704bc5edcb') !== -1 && (
                <AddDataButton
                    OptionsEvent={OptionsEvent}
                    url={url}
                    type="primary"
                    icon="add"
                    title="新增安全问题类别"
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.code, rules: true },
            { ...commonTableList.tableName, title: '安全问题类别' },
            {
                ...commonTableList.parentUuid,
                fieldProps: {
                    fieldNames: { label: 'tableName', value: 'uuid' },
                    options: parentUuid,
                },
            },
            {
                dataIndex: 'score',
                title: '分数',
                valueType: 'inputNumber',
                width: 200,
            },
            { ...commonTableList.sortId, rules: true },
            commonTableList.remark,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'c610ece9-dbbe-42fe-9d7d-a74958d3496e') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '23b97bed-7bcb-4b49-8612-e42645b10b47') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    // data.columns.find(v => v.dataIndex === 'parentUuid').fieldProps.options = await setFieldPropsOptions({
    //     url: 'getSecurityProblemTypeTree',
    // })
    return data
}
